﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data;

namespace CNVP.JShop.Web.Controls
{
    /// <summary>
    /// GetCommon 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    public class GetCommon : System.Web.Services.WebService
    {
        /// <summary>
        /// 获取背景图片
        /// </summary>
        [WebMethod]
        public string GetColumnByID(int ID)
        {
            Model.CNVP_Column model = new Model.CNVP_Column();
            if (ID != 0)
            {
                model = new BLL.CNVP_Column().GetSingle_CNVP_ColumnById(ID);
                if (model != null)
                {
                    return model.ColumnName + "|" + "../UploadFile/File/" + model.ColumnUrl;
                }
                else
                {
                    return "error.gif";
                }
            }
            else
            {
                return "error.gif";
            }
        }

        /// <summary>
        /// 添加，生成列的主键外列构成的参数列表
        /// </summary>
        [WebMethod]
        public bool Array_DeliveryTemplate(int DeliveryTemplateClassID, string Str_RectangleName, string Str_ItemName, string Str_MarginTop, string Str_MarginLeft, string Str_RectangleWidth, string Str_RectangleHight)
        {
            if (DeliveryTemplateClassID != 0)
            {
                new BLL.CNVP_DeliveryTemplate().Delete_CNVP_DeliveryTemplate(DeliveryTemplateClassID);
                string[] Array_RectangleName = Str_RectangleName.Split(Convert.ToChar("|"));
                string[] Array_ItemName = Str_ItemName.Split(Convert.ToChar("|"));
                string[] Array_MarginTop = Str_MarginTop.Split(Convert.ToChar("|"));
                string[] Array_MarginLeft = Str_MarginLeft.Split(Convert.ToChar("|"));
                string[] Array_RectangleWidth = Str_RectangleWidth.Split(Convert.ToChar("|"));
                string[] Array_RectangleHight = Str_RectangleHight.Split(Convert.ToChar("|"));
                if (Array_RectangleName.Length > 0)
                {
                    for (int i = 0; i < Array_RectangleName.Length; i++)
                    {
                        new BLL.CNVP_DeliveryTemplate().Add_CNVP_DeliveryTemplate(new Model.CNVP_DeliveryTemplate()
                        {
                            DeliveryTemplateClassID = DeliveryTemplateClassID,
                            RectangleName = Array_RectangleName[i].ToString(),
                            ItemName = Array_ItemName[i].ToString(),
                            MarginTop = decimal.Parse(Array_MarginTop[i].ToString()),
                            MarginLeft = decimal.Parse(Array_MarginLeft[i].ToString()),
                            RectangleWidth = decimal.Parse(Array_RectangleWidth[i].ToString()),
                            RectangleHight = decimal.Parse(Array_RectangleHight[i].ToString())
                        });
                    }
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 查看列表
        /// </summary>
        [WebMethod]
        public List<Model.CNVP_DeliveryTemplate> GetAll_DeliveryTemplate(string sqlWhere)
        {
            return new BLL.CNVP_DeliveryTemplate().GetAll_CNVP_DeliveryTemplate(sqlWhere);
        }
        
        /// <summary>
        /// 收货人信息,订单信息等
        /// </summary>
        [WebMethod]
        public Model.CNVP_Order GetDeliveryInfoById(int ID)
        {
            return new BLL.CNVP_Order().GetDeliveryInfoById(ID);
        }

        /// <summary>
        /// 发货人信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        [WebMethod]
        public Model.CNVP_PostAddress GetPostAddressById(int ID)
        {
            return new BLL.CNVP_PostAddress().GetDeliveryInfoById(ID);
        }


    }
}
